package com.example.yskjproject.adapter;

import android.annotation.SuppressLint;
import android.content.Context;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.yskjproject.R;
import com.example.yskjproject.model.LeftMenuModel;

import java.util.List;

/**
 * ScreenAdapter  筛选rv
 * <p>
 * 作者：zx
 * 创建时间：2024/4/18
 */
public class ScreenAdapter extends BaseQuickAdapter<LeftMenuModel, BaseViewHolder> {
    Context context;
    public ScreenAdapter(int layoutResId, @Nullable List<LeftMenuModel> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @SuppressLint({"NewApi", "UseCompatLoadingForDrawables"})
    @Override
    protected void convert(BaseViewHolder helper, LeftMenuModel item) {
        helper.setText(R.id.screen_tv,item.getName());
        helper.addOnClickListener(R.id.screen_tv);
        AppCompatTextView screenTv = helper.getView(R.id.screen_tv);
        if (item.isSelect()) {
            screenTv.setBackground(context.getDrawable(R.drawable.btn_ty5));
            screenTv.setTextColor(context.getColor(R.color.black));
        } else {
            screenTv.setBackground(context.getDrawable(R.color.back_main));
            screenTv.setTextColor(context.getColor(R.color.text_bg4));
        }
    }
}
